<extend name="Public/base" />
<!-- 界面样式 -->
<block name="style">
    <!-- 引入页样式文件 -->
    <link href="__CSS__/specialoffer.min.css?v={:C('CURRENT_FILE_VERSION')}" rel="stylesheet" />
    <link rel="stylesheet" href="__PUBLIC__/Admin/css/dropload.css" rel="stylesheet" />
        <style>
    {
        margin: 0;
        padding:0;
        -webkit-tap-highlight-color:rgba(0,0,0,0);
        -webkit-text-size-adjust:none;
    }
    html{
        font-size:10px;
    }
    body{
        background-color: #f5f5f5;
        font-size: 1.2em;
    }
    .outer{
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -ms-flex-direction:column;
        -webkit-box-orient:vertical;
        box-orient:vertical;
        -webkit-flex-direction:column;
        flex-direction:column;
    }
    .header{
        position: relative;
        height: 44px;
        line-height: 44px;
        border-bottom: 1px solid #ccc;
        background-color: #eee;
    }
    .header h1{
        text-align: center;
        font-size: 2rem;
        font-weight: normal;
    }
    .header .btn{
        position: absolute;
        right: 0;
        top: 0;
        width: 4em;
        height: 100%;
        text-align: center;
        color: #06c;
        font-size: 1.4rem;
        background-color: #ccc;
    }
    .header .btn:active{
        background-color: #aaa;
        color: #fff;
    }
    .inner{
        -webkit-box-flex: 1;
        -webkit-flex: 1;
        -ms-flex: 1;
        flex: 1;
        background-color: #fff;
     /*   overflow-y: scroll;*/
        -webkit-overflow-scrolling: touch;
    }
    .inner .item{
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -ms-flex-align:center;
        -webkit-box-align:center;
        box-align:center;
        -webkit-align-items:center;
        align-items:center;
        padding:3.125%;
        border-bottom: 1px solid #ddd;
        color: #333;
        text-decoration: none;
    }
    .inner .item img{
        display: block;
        width: 40px;
        height: 40px;
        border:1px solid #ddd;
    }
    .inner .item h3{
        display: block;
        -webkit-box-flex: 1;
        -webkit-flex: 1;
        -ms-flex: 1;
        flex: 1;
        width: 100%;
        max-height: 40px;
        overflow: hidden;
        line-height: 20px;
        margin: 0 10px;
        font-size: 1.25rem;
    }
    .inner .item .date{
        display: block;
        height: 20px;
        line-height: 20px;
        color: #999;
    }
    .opacity{
        -webkit-animation: opacity 0.5s linear;
        animation: opacity 0.5s linear;
    }
    @-webkit-keyframes opacity {
        0% {
            opacity:0;
        }
        100% {
            opacity:1;
        }
    }
    @keyframes opacity {
        0% {
            opacity:0;
        }
        100% {
            opacity:1;
        }
    }
    .weui_media_box .weui_media_title{
        height: 50px;
    overflow: hidden;
    text-overflow:ellipsis;
    -o-text-overflow:ellipsis; 
    white-space:nowrap;


    }
    .goods{
        font-size: 0.95em;
    }
/*    .goods_item{
        width: 100%;
        clear:both ;

    }*/
    </style>
</block>
<block name="body">


    <div class="weui_panel weui_panel_access"> 
      <div class="weui_panel_hd module_title">特价商品</div>
        <div class="weui_panel_bd">
         <div class="inner">
          <div class="lists">

        </div>
        </div>
        </div> 
    </div>





</block>
<!-- 脚本代码必须写在   block name="script" 标签里 -->
<block name="script">
<script src="__PUBLIC__/Admin/js/dropload.min.js"></script>
<script>

var url = '{:U("Specialoffer/selectlist")}';
var pageSize = 7;
    if($(window).width()>640 &&$(window).height()>450){
       pageSize = 14 ;
    }
    if($(window).width()>900 &&$(window).height()>450){
       pageSize = 18 ;
    }
$(function(){
    var pageNow =1;
    var dropload = $('.inner').dropload({
        domUp : {
            domClass   : 'dropload-up',
            domRefresh : '<div class="dropload-refresh">↓下拉刷新</div>',
            domUpdate  : '<div class="dropload-update">↑释放更新</div>',
            domLoad    : '<div class="dropload-load"><span class="loading"></span>加载中...</div>'
        },
        domDown : {
            domClass   : 'dropload-down',
            //domRefresh : '<div class="dropload-refresh">↑上拉加载更多</div>',
            domRefresh   :"",
        /*    domLoad    : '<div class="dropload-load"><span class="loading"></span>加载中...</div>',*/
            domLoad :"",
            /*domNoData  : '<div class="dropload-noData">暂无数据</div>'*/
            domNoData : ""
        },
        scrollArea : window,
        loadUpFn : function(me){
            $.ajax({
                type: 'GET',
                url: url,
               /* dataType: 'json',*/
                 data:{
                     pageSize:pageSize
                 },
               success: function(data){
                    var data =  $.parseJSON(data);
                    var result = '';
                   for(var i = 0; i < data.length; i++){
                        result +=   ' <a href="javascript:void(0);" class="weui_media_box weui_media_appmsg goods_item">'
                                        +'<div class="weui_media_hd">'
                                        +'<img class="weui_media_appmsg_thumb" src="/'+data[i]['goods_thumb']+'" alt=""> </div>'
                                        +' <div class="weui_media_bd">'
                                        +'<h4 class="weui_media_title">['+data[i]['salename']+']<span class="goods">'+data[i]['goods_name']+'</span></h4>'
                                        +'<p class="weui_media_desc">包邮重量：'+(data[i]['goods_weight']*1000)+'克/桶</p>'
                                        +'<div class="goods_price">'+data[i]['price']+'澳元/罐</div>'
                                        +' </div>   </a>';
                    }
                       /*$('.dropload-up').remove();*/
                        $('.lists').html(result);
                        // 每次数据加载完，必须重置
                        dropload.resetload();
                         dropload.unlock();
                        pageNow =2;
               
                },
                error: function(xhr, type){
                    alert('Ajax error!');
                    // 即使加载出错，也得重置
                    dropload.resetload();
                }
            });
        },
        loadDownFn : function(me){
            $.ajax({
                type: 'GET',
                url: url,
               /* dataType: 'json',*/
               data:{pageNow:pageNow,
                     pageSize:pageSize
                 },
                success: function(data){
                if(data == ""){
                       dropload.lock();
                       dropload.noData();
                       dropload.resetload();
                    //alert('没有数据啦!');
                }else{

                    var data = $.parseJSON(data);
                    var result = '';
                   for(var i = 0; i < data.length; i++){
                        result +=   ' <a href="javascript:void(0);" class="weui_media_box weui_media_appmsg goods_item">'
                                        +'<div class="weui_media_hd">'
                                        +'<img class="weui_media_appmsg_thumb" src="/'+data[i]['goods_thumb']+'" alt=""> </div>'
                                        +' <div class="weui_media_bd">'
                                        +'<h4 class="weui_media_title">['+data[i]['salename']+']<span class="goods">'+data[i]['goods_name']+'</span></h4>'
                                        +'<p class="weui_media_desc">包邮重量：'+(data[i]['goods_weight']*1000)+'克/桶</p>'
                                        +'<div class="goods_price">'+data[i]['price']+'澳元/罐</div>'
                                        +' </div>   </a>';
                    }

                        $('.lists').append(result);
                        pageNow ++;
                        if(data.length < pageSize){
                            dropload.lock();
                            dropload.noData();
                        }
                        dropload.resetload();
                  
                  }
                },
                error: function(xhr, type){
                    alert('Ajax error!');
                    // 即使加载出错，也得重置
                    dropload.resetload();
                }
            });
        }
    });
});
</script>    
  
     
</block>
